Inside Macintosh: QuickTime Components

Previous | Chapter Top | Chapter Contents | Next

Configuration Functions for Sound Channel Components

Sound channel components provide a number of functions that allow sequence grabber components to configure the component's sound channel. This section describes these sound channel configuration functions. The sequence grabber component uses these functions only with sound channels.

The SGSetChannelVolume function allows the sequence grabber component to control a channel's sound volume. The sequence grabber component uses the SGGetChannelVolume function to determine a channel's volume.

The SGSetSoundInputDriver specifies a channel's sound input device. The sequence grabber component can determine a channel's sound input device by calling the SGGetSoundInputDriver function. If an application changes any attributes of the sound input device, the sequence grabber component notifies your sound component by calling the SGSoundInputDriverChanged function.

The sequence grabber component can control the amount of sound data your channel works with at one time by calling the SGSetSoundRecordChunkSize function. The sequence grabber component can determine this value by calling the SGGetSoundRecordChunkSize function.

The sequence grabber component controls the rate at which your sound channel samples the input data by calling the SGSetSoundInputRate function. The sequence grabber component can determine the sample rate by calling the SGGetSoundInputRate function.

The sequence grabber can control other sound input parameters by using your SGSetSoundInputParameters and SGGetSoundInputParameters functions.

SGSetChannelVolume

The SGSetChannelVolume function sets your channel's sound volume.

pascal ComponentResult SGSetChannelVolume (SGChannel c,
                                          short volume);
c
Identifies the channel connection for this operation.
volume
Specifies the volume setting of your channel represented as a 16-bit, fixed-point number. The high-order 8 bits contain the integer part of the value; the low-order 8 bits contain the fractional part. Volume values range from -1.0 to 1.0. Negative values play no sound but preserve the absolute value of the volume setting.

DESCRIPTION

Use this volume setting during playback--this setting should not affect the record level or the volume of the track in the recorded QuickTime movie.

SGGetChannelVolume

The SGGetChannelVolume function allows the sequence grabber component to determine your channel's sound volume setting.

pascal ComponentResult SGGetChannelVolume (SGChannel c,
                                          short *volume);
c
Identifies the channel connection for this operation.
volume
Contains a pointer to an integer that is to receive the volume setting of the channel represented as a 16-bit, fixed-point number. The high-order 8 bits contain the integer part of the value; the low-order 8 bits contain the fractional part. Volume values range from -1.0 to 1.0. Negative values play no sound but preserve the absolute value of the volume setting.

SEE ALSO

The sequence grabber component establishes the volume setting by calling the SGSetChannelVolume function, described in the previous section.

SGSetSoundInputDriver

Some sound channel components may use sound input devices to obtain their source data. The SGSetSoundInputDriver function allows the sequence grabber component to assign a sound input device to your sound channel.

pascal ComponentResult SGSetSoundInputDriver (SGChannel c,
                                         ConstStr255Param driverName);
c
Identifies the channel connection for this operation.
driverName
Specifies the name of the sound input device. This is a Pascal string, and it must correspond to a valid sound input device.

DESCRIPTION

If your sound channel component does not use sound input devices, return a nonzero result code.

RESULT CODES

noDeviceForChannel

-9400

Channel component cannot find its device

cantDoThatInCurrentMode

-9402

Request invalid in current mode

deviceCantMeetRequest

-9408

Device cannot support grabber

SEE ALSO

For more information about sound input devices, see Inside Macintosh: More Macintosh Toolbox --in particular, refer to the discussion of the SPBGetIndexedDevice function in the chapter "Sound Manager."

SGGetSoundInputDriver

The SGGetSoundInputDriver function allows the sequence grabber component to determine the sound input device currently in use by your sound channel component.

pascal long SGGetSoundInputDriver (SGChannel c);
c
Identifies the channel connection for this operation.

DESCRIPTION

The sequence grabber component may want to gain access to the sound input device if it wants to change the device's configuration. For example, the sequence grabber component may want to configure the device for stereo sound. If the sequence grabber component changes any of the device's operating parameters, it informs your sequence grabber channel component by calling your SGSoundInputDriverChanged function, which is described in the next section.

The SGGetSoundInputDriver function returns a reference to the sound input device. If your sound channel is not using a sound input device, set the returned value to nil .

SEE ALSO

The sequence grabber component can assign a sound input device to a sound channel by calling the SGSetSoundInputDriver function, which is described in the previous section.

SGSoundInputDriverChanged

The SGSoundInputDriverChanged function allows the sequence grabber component to notify your sound channel component whenever an application changes the configuration of your sound channel's sound input device.

pascal ComponentResult SGSoundInputDriverChanged (SGChannel c);
c
Identifies the channel connection for this operation.

DESCRIPTION

Your component should update any sound device status information it maintains.

SGSetSoundRecordChunkSize

During record operations, the sequence grabber component and its sound channels work with groups of sound samples. These groups are referred to as chunks . By default, each chunk contains two seconds of sound data. Smaller chunks use less memory.

pascal ComponentResult SGSetSoundRecordChunkSize (SGChannel c,
                                         long seconds);
c
Identifies the channel connection for this operation.
seconds
Specifies the number of seconds of sound data your sound channel component is to work with at a time. This parameter is set to a negative fixed-point number to specify a fraction of a second. For example, to set the duration to half a second, -0.5 is passed in.

DESCRIPTION

The sequence grabber component can control the amount of sound data in each chunk by calling the SGSetSoundRecordChunkSize function. The sequence grabber component specifies the number of seconds of sound data your channel is to work with at a time.

SPECIAL CONSIDERATIONS

The SGSetSoundRecordChunkSize function may return a fraction of a second (see the discussion of the seconds parameter above).

RESULT CODES

paramErr

-50

Invalid parameter specified

cantDoThatInCurrentMode

-9402

Request invalid in current mode

SGGetSoundRecordChunkSize

The SGGetSoundRecordChunkSize function allows the sequence grabber component to determine the amount of sound data your sound channel component works with at a time.

pascal long SGGetSoundRecordChunkSize (SGChannel c);
c
Identifies the channel connection for this operation.

DESCRIPTION

The SGGetSoundRecordChunkSize function returns a long integer that specifies the number of seconds of sound data your channel works with at a time.

SEE ALSO

The sequence grabber component sets this value by calling the SGSetSoundRecordChunkSize function, which is described in the previous section.

SGSetSoundInputRate

The SGSetSoundInputRate function allows the sequence grabber component to set the rate at which your sound channel obtains its sound data.

pascal ComponentResult SGSetSoundInputRate (SGChannel c,
                                         Fixed rate);
c
Identifies the channel connection for this operation.
rate
Specifies the rate at which your sound channel is to acquire data. This parameter specifies the number of samples your sound channel is to generate per second. If your sound channel cannot support the specified rate, use the closest available rate that you can support. If this parameter is set to 0, use your default rate.

RESULT CODES

cantDoThatInCurrentMode

-9402

Request invalid in current mode

deviceCantMeetRequest

-9408

Device cannot support grabber

SGGetSoundInputRate

The SGGetSoundInputRate function allows the sequence grabber component to determine the rate at which your sound channel is collecting sound data .

pascal Fixed SGGetSoundInputRate (SGChannel c);
c
Identifies the channel connection for this operation.

DESCRIPTION

The SGGetSoundInputRate function returns a fixed-point number that indicates the number of samples your sound channel collects per second.

SEE ALSO

The sequence grabber component sets this rate by calling the SGSetSoundInputRate function, which is described in the previous section.

SGSetSoundInputParameters

The SGSetSoundInputParameters function allows the sequence grabber to set some parameters that relate to sound recording.

pascal ComponentResult SGSetSoundInputParameters (SGChannel c,
                                          short sampleSize,
                                          short numChannels,
                                          OSType compressionType);
c
Identifies the channel connection for this operation.
sampleSize
Specifies the number of bits in each sound sample. This field is set to 8 for 8-bit sound; it is set to 16 for 16-bit sound.
numChannels
Indicates the number of sound channels to be used by the sound sample. This field is set to 1 for monaural sounds; it is set to 2 for stereo sounds.
compressionType
Describes the format of the sound data. The following values are supported:
'raw '
Sound samples are uncompressed, in offset-binary format (that is, sample data values range from 0 to 255).
'MAC3'
Sound samples have been compressed by the Sound Manager at a ratio of 3:1.
'MAC6'
Sound samples have been compressed by the Sound Manager at a ratio of 6:1.

DESCRIPTION

Sequence grabbers may use the SGSetSoundInputParameters function to control many parameters relating to sound recording. All of the sound parameters support two special values. If any of these parameters are set to 0, your channel should not change the current value of that parameter. If any are set to -1, return that parameter to its default value.

If your sound device cannot support a specified parameter value, return an appropriate Sound Manager result code.

RESULT CODES

Sound Manager errors

SGGetSoundInputParameters

The SGGetSoundInputParameters function allows the sequence grabber to retrieve some parameters that relate to sound recording.

pascal ComponentResult SGGetSoundInputParameters (SGChannel c,
                                         short *sampleSize,
                                         short *numChannels,
                                         OSType *compressionType);
c
Identifies the channel connection for this operation.
sampleSize
Contains a pointer to a field to receive the sample size. Set this field to 8 for 8-bit sound; set the field to 16 for 16-bit sound.
numChannels
Contains a pointer to a field to receive the number of sound channels used by the sound sample. Set this field to 1 for monaural sounds; set the field to 2 for stereo sounds.
compressionType
Contains a pointer to a field to receive the format of the sound data. You may return the following values:
'raw '
Sound samples are uncompressed, in offset-binary format (that is, sample data values range from 0 to 255).
'MAC3'
Sound samples have been compressed by the Sound Manager at a ratio of 3:1.
'MAC6'
Sound samples have been compressed by the Sound Manager at a ratio of 6:1.

DESCRIPTION

The sequence grabber may use the SGGetSoundInputParameters function to retrieve many parameters relating to sound recording. If any of the sound parameters are set to nil , do not return that value.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next